package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class PhotoActivity extends AppCompatActivity {
    Button btn,btn1,btn2,btn3;
    ImageView img;
    boolean flag=false;
    private int i=0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn=findViewById(R.id.button_next);
        btn1=findViewById(R.id.button_juzhao);
        btn2=findViewById(R.id.button_yanyuan);
        btn3=findViewById(R.id.button_back);
        img=findViewById(R.id.imageView);
        btnBack();
        btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                i=i%3;
                if(flag) {
                    switch (i) {
                        case 0:
                            img.setBackgroundResource(R.drawable.juzhao1);
                            i++;
                            break;
                        case 1:
                            img.setBackgroundResource(R.drawable.juzhao2);
                            i++;
                            break;
                        case 2:
                            img.setBackgroundResource(R.drawable.juzhao3);
                            i++;
                            break;
                    }
                }
                else{

                    switch (i) {
                        case 0:
                            img.setBackgroundResource(R.drawable.bailu);
                            i++;
                            break;
                        case 1:
                            img.setBackgroundResource(R.drawable.zhaojinmai);
                            i++;
                            break;
                        case 2:
                            img.setBackgroundResource(R.drawable.liangjie);
                            i++;
                            break;
                    }
                }
            }
        });
        btn1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                img.setBackgroundResource(R.drawable.juzhao1);
                flag=true;
            }
        });
        btn2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                img.setBackgroundResource(R.drawable.bailu);
                flag=false;
            }
        });
    }
        private void btnBack() {
            btn3.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent= new Intent();
                    intent.setClass(PhotoActivity.this,MainActivity6.class);
                    startActivity(intent);
                }
            });
        }
}
